<template>
	<view>
		<u-card title="信息修改">
			<view class="" slot="body">
				<u-form :model="userInfo">
					<u-form-item label="姓名">
						<u-input v-model="userInfo.user"></u-input>
					</u-form-item>
					<u-form-item label="大学">
						<u-input v-model="userInfo.school" :disabled="true"></u-input> <u-button type="info" size="mini" @click="selectShow=true" >选择</u-button> <u-select v-model="selectShow" mode="single-column" :list="schoollist" @confirm="confirmSchool"></u-select>
					</u-form-item>
					<u-form-item label="电话">
						<u-input v-model="userInfo.pho"></u-input>
					</u-form-item>
				</u-form>
			</view>
		</u-card>
		<u-button type="primary" @click="isShow=true">确定修改</u-button>
		<u-popup v-model="isShow" mode='center'>
			<view class="">
				<u-alert-tips type="warning" :show-icon="true" :title="alertInfo.title" :description="alertInfo.description"></u-alert-tips>
				<u-button @click="goback">确定</u-button>
			</view>
					
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo:{},
				isShow:false,
				alertInfo:{
					title:"改动提示",
					description:"请再次确认是否修改，点击其他地方退出"
				},
				selectShow:false,
				
				schoollist:[
					{
						value:"西南石油大学",
						label:"西南石油大学"
					},
					{
						value:"成都理工大学",
						label:"成都理工大学"
					},
				]
			};
		},
		onLoad(options){
			this.userInfo= JSON.parse(options.info)
		},
		methods:{
			confirmBtn(){
				
			},
			confirmSchool(valueArray){
				console.log(valueArray)
				this.userInfo.school = valueArray[0].label
			},
			async goback(){
				const res = await this.$myRequest({
					url: 'UserController/modifyInformation',
					data: {
					  userid: this.userInfo.id,
					  name: this.userInfo.user,
					  school: this.userInfo.school,
					  phonenumber:this.userInfo.pho
					},
					method: 'POST'
				});
				if(res.statusCode==200){
					uni.showToast({
						title:"修改成功"
					});
					setTimeout(function(){
						uni.navigateBack()
					},1000);
				}
			}
		}
	}
</script>

<style lang="scss">

</style>
